home *** CD-ROM | disk | FTP | other *** search
/ Turnbull China Bikeride / Turnbull China Bikeride - Disc 2.iso / STUTTGART / LANG / ADA / GNAT / !gcc / adainc / 2 / adb / a-tideio < prev    next >
Text File  |  1996-02-12  |  5KB  |  139 lines

  1. ------------------------------------------------------------------------------
  2. --                                                                          --
  3. --                         GNAT RUNTIME COMPONENTS                          --
  4. --                                                                          --
  5. --               A D A . T E X T _ I O . D E C I M A L _ I O                --
  6. --                                                                          --
  7. --                                 B o d y                                  --
  8. --                                                                          --
  9. --                            $Revision: 1.6 $                              --
  10. --                                                                          --
  11. --     Copyright (C) 1992,1993,1994, 1995 Free Software Foundation, Inc.    --
  12. --                                                                          --
  13. -- GNAT is free software;  you can  redistribute it  and/or modify it under --
  14. -- terms of the  GNU General Public License as published  by the Free Soft- --
  15. -- ware  Foundation;  either version 2,  or (at your option) any later ver- --
  16. -- sion.  GNAT is distributed in the hope that it will be useful, but WITH- --
  17. -- OUT ANY WARRANTY;  without even the  implied warranty of MERCHANTABILITY --
  18. -- or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License --
  19. -- for  more details.  You should have  received  a copy of the GNU General --
  20. -- Public License  distributed with GNAT;  see file COPYING.  If not, write --
  21. -- to  the Free Software Foundation,  59 Temple Place - Suite 330,  Boston, --
  22. -- MA 02111-1307, USA.                                                      --
  23. --                                                                          --
  24. -- As a special exception,  if other files  instantiate  generics from this --
  25. -- unit, or you link  this unit with other files  to produce an executable, --
  26. -- this  unit  does not  by itself cause  the resulting  executable  to  be --
  27. -- covered  by the  GNU  General  Public  License.  This exception does not --
  28. -- however invalidate  any other reasons why  the executable file  might be --
  29. -- covered by the  GNU Public License.                                      --
  30. --                                                                          --
  31. -- GNAT was originally developed  by the GNAT team at  New York University. --
  32. -- It is now maintained by Ada Core Technologies Inc (http://www.gnat.com). --
  33. --                                                                          --
  34. ------------------------------------------------------------------------------
  35.  
  36. with Ada.Text_IO.Decimal_Aux;
  37.  
  38. package body Ada.Text_IO.Decimal_IO is
  39.  
  40.    package Aux renames Ada.Text_IO.Decimal_Aux;
  41.  
  42.    Scale : constant Integer := Num'Scale;
  43.  
  44.    ---------
  45.    -- Get --
  46.    ---------
  47.  
  48.    procedure Get
  49.      (File  : in File_Type;
  50.       Item  : out Num;
  51.       Width : in Field := 0)
  52.    is
  53.    begin
  54.       if Num'Size > Integer'Size then
  55.          Item := Num'Fixed_Value (Aux.Get_LLD (File, Width, Scale));
  56.  
  57.       else
  58.          Item := Num'Fixed_Value (Aux.Get_Dec (File, Width, Scale));
  59.       end if;
  60.  
  61.    exception
  62.       when Constraint_Error => raise Data_Error;
  63.    end Get;
  64.  
  65.    procedure Get
  66.      (Item  : out Num;
  67.       Width : in Field := 0)
  68.    is
  69.    begin
  70.       Get (Current_In, Item, Width);
  71.    end Get;
  72.  
  73.    procedure Get
  74.      (From : in String;
  75.       Item : out Num;
  76.       Last : out Positive)
  77.    is
  78.    begin
  79.       if Num'Size > Integer'Size then
  80.          Item := Num'Fixed_Value
  81.                    (Aux.Gets_LLD (From, Last'Unrestricted_Access, Scale));
  82.       else
  83.          Item := Num'Fixed_Value
  84.                    (Aux.Gets_Dec (From, Last'Unrestricted_Access, Scale));
  85.       end if;
  86.  
  87.    exception
  88.       when Constraint_Error => raise Data_Error;
  89.    end Get;
  90.  
  91.    ---------
  92.    -- Put --
  93.    ---------
  94.  
  95.    procedure Put
  96.      (File : in File_Type;
  97.       Item : in Num;
  98.       Fore : in Field := Default_Fore;
  99.       Aft  : in Field := Default_Aft;
  100.       Exp  : in Field := Default_Exp)
  101.    is
  102.    begin
  103.       if Num'Size > Integer'Size then
  104.          Aux.Put_LLD
  105.            (File, Long_Long_Integer'Integer_Value (Item),
  106.             Fore, Aft, Exp, Scale);
  107.       else
  108.          Aux.Put_Dec
  109.            (File, Integer'Integer_Value (Item), Fore, Aft, Exp, Scale);
  110.       end if;
  111.    end Put;
  112.  
  113.    procedure Put
  114.      (Item : in Num;
  115.       Fore : in Field := Default_Fore;
  116.       Aft  : in Field := Default_Aft;
  117.       Exp  : in Field := Default_Exp)
  118.    is
  119.    begin
  120.       Put (Current_Out, Item, Fore, Aft, Exp);
  121.    end Put;
  122.  
  123.    procedure Put
  124.      (To   : out String;
  125.       Item : in Num;
  126.       Aft  : in Field := Default_Aft;
  127.       Exp  : in Field := Default_Exp)
  128.    is
  129.    begin
  130.       if Num'Size > Integer'Size then
  131.          Aux.Puts_LLD
  132.            (To, Long_Long_Integer'Integer_Value (Item), Aft, Exp, Scale);
  133.       else
  134.          Aux.Puts_Dec (To, Integer'Integer_Value (Item), Aft, Exp, Scale);
  135.       end if;
  136.    end Put;
  137.  
  138. end Ada.Text_IO.Decimal_IO;
  139.